package com.fy.tt.utils;

import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;

public class CmdExec {
    public static boolean cmd(String command,String execPath){
        boolean flag = false;
        String line = null;
        StringBuilder sb = new StringBuilder();
        try {
            Process exec = Runtime.getRuntime().exec("cmd.exe /k " + command, null, new File(execPath));
            BufferedReader bufferedReader = new BufferedReader
                    (new InputStreamReader(exec.getInputStream(),"gbk"));

            while ((line = bufferedReader.readLine()) != null) {
                sb.append(line + "\n");
                System.out.println(line);
                if (line.length() < 1) {
                    break;
                }
            }
            flag = true;
        }catch (Exception e){
            e.printStackTrace();
        }
        return flag;
    }
}
